<?php
$gmc= new GearmanClient();
$gmc->addServer();
$gmc->setCompleteCallback("_complete");
$args = array("url"=>"http://caipiao.taobao.com/lottery/order/united_list.htm?lottery_type=SSQ","encode"=>"gb2312","reg"=>"/<option.*?value=\"(\d*)[^>]*>(\d*)</ims");
$workload = serialize($args);
for($i=0;$i<2;$i++){
	$gmc->addTask("urlresult", $workload, NULL);
}
if (! $gmc->runTasks())
{
    echo "ERROR " . $gmc->error() . "\n";
    exit;
}
echo "DONE\n";
function _complete($task)
{
    echo "COMPLETE: " . $task->jobHandle() . ":\n";
    print_r( unserialize($task->data()));
}
?>
